<template>
  <div class="method-box">
    <h6 class="w-40" @click="submitForm">工程方法1:</h6>
    <div>
      <el-form ref="formRef" :model="form" label-width="auto" :rules="rules">
        <div>
          评分点计算公式：有效供应商价格分的计算：
          <div class="flex gap-1">
            （1）有效投标报价等于评标基准价的，报价得分=
            <el-form-item prop="scoreP">
              <el-input
                v-model.number="form.scoreP"
                :disabled="disabled"
                class="text-input"
                size="small"
                clearable
                type="number"
                placeholder="P"
                @change="reflectChange"
              />
            </el-form-item>
            分（默认评分点的最高分）。
          </div>
          <div class="flex gap-1">
            （2）如果投标人的有效投标报价＞评标基准价，则报价得分=P﹣|偏差率|×100×
            <el-form-item prop="scoreE1">
              <el-input
                v-model.number="form.scoreE1"
                :disabled="disabled"
                class="text-input"
                size="small"
                clearable
                type="number"
                placeholder="E1"
                @change="reflectChange"
              />
            </el-form-item>
            ；
          </div>
          <div class="flex gap-1">
            （3）如果投标人的有效投标报价≦评标基准价，则报价得分=P﹣|偏差率|×100×
            <el-form-item prop="scoreE2">
              <el-input
                v-model.number="form.scoreE2"
                :disabled="disabled"
                class="text-input"
                size="small"
                clearable
                type="number"
                placeholder="E2"
                @change="reflectChange"
              />
            </el-form-item>
            ；
          </div>
          <div class="flex gap-1">
            其中：E1是投标报价每高于评标基准价一个百分点的扣分值；E2是投标报价每低于评标基准价一个百分点的扣分值
          </div>
          <div class="flex gap-1">偏差率=100%×（评标基准价-投标人有效投标报价）/评标基准价</div>
          <div class="flex gap-1 flex-wrap">
            评标基准价:=
            <el-form-item prop="scoreA">
              <el-input
                v-model.number="form.scoreA"
                :disabled="true"
                class="text-input"
                size="small"
                clearable
                type="number"
                placeholder="A"
                @change="reflectChange"
              />
            </el-form-item>
            ×
            <el-form-item prop="scoreK">
              <el-input
                v-model.number="form.scoreK"
                :disabled="disabled"
                class="text-input"
                size="small"
                clearable
                type="number"
                placeholder="K"
                @change="reflectChange"
              >
                <template #suffix>%</template>
              </el-input>
            </el-form-item>
            <div>
              {{ ENGINEERING_METHOD }}
            </div>
          </div>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ENGINEERING_METHOD } from '../data'
const emit = defineEmits(['value-change'])
const reflectChange = () => {
  emit('value-change')
}
const rules = ref<any>({
  scoreP: [{ required: true, message: '请输入scoreP' }],
  scoreE1: [{ required: true, message: '请输入scoreE1' }],
  scoreE2: [{ required: true, message: '请输入scoreE2' }],
  scoreK: [{ required: true, message: '请输入scoreK' }]
})
const form = ref<any>({
  scoreP: '',
  scoreE1: '',
  scoreE2: '',
  scoreA: '',
  scoreK: ''
})
const props = defineProps({
  formData: {
    type: Object,
    required: true
  },
  disabled: {
    type: Boolean,
    default: false
  }
})
const init = () => {
  form.value = props.formData
}
onMounted(() => {
  init()
})
const formRef = ref()
const submitForm = async () => {
  const res = await formRef.value.validate()
  return res
}
defineExpose({ form, submitForm })
</script>
<style scoped lang="scss" src="./text-common.scss"></style>
